<template>
	<view class="fixtop">
		<fixtitletopVue>
			<template #l>
				<view class="fix-l" @click="back">
					<view>
						<view class="iconfont icon-jiantou"></view>
					</view>
				</view>
			</template>
			<template #c>
				<view class="fix-c">
					我的收藏
				</view>
			</template>
		</fixtitletopVue>
	</view>
	<scroll-view class="conbox" scroll-y @scrolltolower="scrollbottom">
		  <view class="" v-for="(i,index) in loveprodata" :key="i.id" @click="goproduct(i)">
			  <productCardVue :data="i" />
		  </view>
		  <uni-load-more :status="curdata.length<7?'no-more':'loading'"></uni-load-more>
	</scroll-view>
</template>

<script setup>
	import {onReady} from "@dcloudio/uni-app"
	import {ref} from 'vue'
	import fixtitletopVue from '../../components/fixtitletop/fixtitletop.vue';
	import productCardVue from '../../components/product-card/product-card.vue';
	import {
		getstatusheight,
		gettitleheight
	} from '@/util/getsysinfo.js'
	import {getlovesdatass} from '@/api/index.js'
	import userstore from '@/store/user.js'
	const useuserstore=userstore()
	const heights=getstatusheight()+gettitleheight()+'px'
	const loveprodata=ref([])
	const curdata=ref([])
	const limit=ref(7)
	const offset=ref(1)
	onReady(()=>{
		getlovedata()
	})
	const scrollbottom=()=>{
		if(curdata.value<7)return
		offset.value++
		getlovedata()
	}
	const getlovedata=async()=>{
		const rudata=await getlovesdatass(useuserstore.userinfo.id,limit.value,offset.value)
		if(rudata.code==200){
			curdata.value=rudata.data
			loveprodata.value=[...loveprodata.value,...rudata.data]
		}
	}
	const goproduct=(i)=>{
		uni.navigateTo({
			url:`/pages/producet-xq/producet-xq?userid=${i.shoperid}&id=${i.id}`
		})
	}
	const back=()=>{
		uni.navigateBack()
	}
</script>

<style lang="scss" scoped>
	.conbox{
		height: calc(100vh - v-bind(heights));
		background-color: #eee;
		overflow: hidden;
		padding: 0 20rpx;
	}
	.fixtop {
		background-color: #eee;
		padding: 0 20rpx;
		border-bottom: 1rpx solid #dcdcdc;
       overflow: hidden;
		.fix-l {
			height: 100%;
			width: 100%;
			display: flex;
			align-items: center;

			.iconfont {
				font-size: 25rpx;
			}
		}

		.fix-c {
			height: 100%;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 30rpx;
		}
	}
</style>